import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Car } from '../../car/entities/car.entity';
import { User } from '../../user/entities/user.entity';
import { Service } from '../../service/entities/service.entity';

@Entity('order')
export class Order {
  @PrimaryGeneratedColumn({ type: 'int' })
  id: number;

  @Column({
    type: 'boolean',
    comment: '是否被删除',
    default: false,
  })
  isDelete: boolean;

  @Column({
    type: 'varchar',
    comment: '订单状态, 0 待处理， 1处理中， 2已完成， 3.已结束',
    default: '0',
  })
  order_status: string;

  @Column({
    type: 'varchar',
    comment: '类型',
    nullable: true,
    default: 'order',
  })
  type: string;

  @ManyToOne(() => Car, (car) => car.order)
  car: Car;

  @ManyToOne(() => User, (user) => user.order)
  user: User;

  @ManyToOne(() => Service, (ser) => ser.order)
  service: Service;

  @Column({
    name: 'create_date',
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  create_date: Date;

  @Column({
    name: 'update_date',
    type: 'timestamp',
    comment: '修改时间',
    nullable: true,
  })
  updated_date: Date;
}
